<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>39 ES6数值扩展</title>
</head>

<body>
    <script>
        //0. Number.EPSILON是avascript表示的最小精度
        //EPSILON属性的值接近于2.2204460492503130808472633361816E-16
        // console.log(Number.EPSILON);
        // console.log(0.1 + 0.2 === 0.3);
        // function equal(a, b) {
        //     return Math.abs(a - b) < Number.EPSILON;
        // }
        // console.log(equal(0.1 + 0.2, 0.3));

        //1．二进制和八进制
        // {
        //     let b = 0b1010;
        //     let o = 0o777;
        //     let d = 100;
        //     let x = 0xff;
        //     console.log(b, o, d, x);
        // }

        //2. Number.isFinite检测一个数值是否为有限数
        // console.log(Number.isFinite(100));           //true
        // console.log(Number.isFinite(100 / 0));       //false
        // console.log(Number.isFinite(Infinity));      //false

        //3. Number.isNaN检测一个数值是否为 NaN
        // console.log(Number.isNaN(123));              //false   

        //4. Number.parseInt Number.parseFloat字符串转整数
        // console.log(Number.parseInt('5211314love'));
        // console.log(Number.parseFloat('3.1415926sq'));

        //5. Number.isInteger判断一个数是否为整数
        // console.log(Number.isInteger(5));
        // console.log(Number.isInteger(5.5));

        //6. Math.trunc将数字的小数部分抹掉
        // console.log(Math.trunc(5.15));               //5
        // console.log(Math.trunc(-5.15));              //-5

        //7. Math.sign判断一个数到底为正数负数还是零
        console.log(Math.sign(100));
        console.log(Math.sign(0));
        console.log(Math.sign(-100));

    </script>
</body>

</html>